package cn.edu.hnu.gpg.dto;

import cn.edu.hnu.gpg.entity.Administrator;
import cn.edu.hnu.gpg.entity.Student;
import cn.edu.hnu.gpg.entity.Teacher;
import cn.edu.hnu.gpg.entity.enums.Gender;
import cn.edu.hnu.gpg.entity.enums.UserType;

import java.util.Date;

public class UniversalUser {

    private Integer userId;
    private String username;
    private UserType userType;
    private boolean active;

    private String name;
    private String idNumber;
    private Gender gender;
    private String phone;
    private Date birthDate;
    private Short departmentId;

    public UniversalUser () {}

    public UniversalUser(Student student) {
        this.userId = student.getUserId();
        this.username = student.getStudentNumber();
        this.userType = UserType.S;

        this.name = student.getName();
        this.idNumber = student.getIdNumber();
        this.gender = student.getGender();
        this.phone = student.getPhone();
        this.birthDate = student.getBirthDate();
        this.departmentId = student.getDepartmentId();
    }

    public UniversalUser(Teacher teacher) {
        this.userId = teacher.getUserId();
        this.username = teacher.getTeacherNumber();
        this.userType = UserType.T;

        this.name = teacher.getName();
        this.idNumber = teacher.getIdNumber();
        this.gender = teacher.getGender();
        this.phone = teacher.getPhone();
        this.birthDate = teacher.getBirthDate();
        this.departmentId = teacher.getDepartmentId();
    }

    public UniversalUser(Administrator administrator) {
        this.userId = administrator.getUserId();
        this.userType = UserType.A;
        this.name = administrator.getName();
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public boolean isActive() {
        return active;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setDepartmentId(Short departmentId) {
        this.departmentId = departmentId;
    }

    public Short getDepartmentId() {
        return departmentId;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public Gender getGender() {
        return gender;
    }

    public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPhone() {
        return phone;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUsername() {
        return username;
    }

    public void setUserType(UserType userType) {
        this.userType = userType;
    }

    public UserType getUserType() {
        return userType;
    }
}
